home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Utilities / MPW Extras / Scripts / NewSave < prev    next >
Encoding:
Text File  |  1991-07-29  |  2.2 KB  |  70 lines  |  [TEXT/MPS ]

  1. # NewSave - replacement "Save" script supporting file backup and remember
  2.  
  3. Set NFile "{#}"                                                                                    # get number of command line arguments
  4. If ({NFile} == 0)
  5.     # no command line arguments - act on active window
  6.     Set LeafName "`ParseFileName -l "{Active}"`"                                                # get the file's leafname
  7.     Save "{Active}" ∑∑ Dev:Null
  8.     If ({Status} == 0)
  9.         # the Save was successful
  10.         Set RemFiles "`Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`"
  11.         If ("{RemFiles}" != "")
  12.             # Remember Files exist
  13.             Set Exit 0
  14.             Confirm "Delete the old Remember files?"
  15.             If ({Status} == 0)
  16.                 # Delete all the old "Remember" backup files
  17.                 For i in "{RemFiles}"
  18.                     Delete {i}
  19.                 End  # For i
  20.             End  # If {Status}
  21.         End  # If RemFiles
  22.     End  # If {Status}
  23. Else
  24.     Loop
  25.         Break If ({NFile} <= 0)                                                                    # exit if all arguments have been processed
  26.         If ("{1}" == "-a")
  27.             # Save all Windows option
  28.             For i in "`Windows -q`"
  29.                 Set LeafName "`ParseFileName -l "{i}"`"                                            # get the file's leafname
  30.                 Save "{i}" ∑∑ Dev:Null
  31.                 If ({Status} == 0)
  32.                     # the Save was successful
  33.                     Set RemFiles "`Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`"
  34.                     If ("{RemFiles}" != "")
  35.                         Set Exit 0
  36.                         Confirm "Delete the old Remember files?"
  37.                         If ({Status} == 0)
  38.                             # Delete all the old "Remember" backup files
  39.                             For j in "{RemFiles}"
  40.                                 Delete {j}
  41.                             End  # For j
  42.                         End  # If {Status}
  43.                     End  # If RemFiles
  44.                 End  # If {Status}
  45.             End  # For i
  46.         Else
  47.             Set LeafName "`ParseFileName -l "{1}"`"                                                # get the file's leafname
  48.             Save "{1}" ∑∑ Dev:Null
  49.             If ({Status} == 0)
  50.                 # the Save was successful
  51.                 Set RemFiles "`Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`"
  52.                 If ("{RemFiles}" != "")
  53.                     # Remember Files exist
  54.                     Set Exit 0
  55.                     Confirm "Delete the old Remember files?"
  56.                     If ({Status} == 0)
  57.                         # Delete all the old "Remember" backup files
  58.                         For i in "{RemFiles}"
  59.                             Delete {i}
  60.                         End  # For i
  61.                     End  # If {Status}
  62.                 End  # If RemFiles
  63.             End  # If {Status}
  64.         Shift
  65.         Evaluate NFile -= 1                                                                        # update the argument counter
  66.         End  # If {1}
  67.     End  # Loop
  68. End  # If {NFile}
  69.  
  70. # end of NewSave